﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.ServiceProxy.MainServiceRef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.ServiceProxy
{
    public class RequestUtil
    {
        public static Request BuildRequest(string domainId, string userIdentity, byte scenario, byte command, byte mode, object requestData)
        {
            RequestHeader requestHeader = new RequestHeader();
            requestHeader.DomainId = domainId;
            requestHeader.Scenario = scenario;
            requestHeader.Command = command;
            requestHeader.SendTicks = DateTime.Now.Ticks;
            requestHeader.UserIdentity = userIdentity;
            requestHeader.Mode = mode;

            Request request = new Request();
            request.Header = requestHeader;

            request.Data = SerializeUtility.SerializeToBinary(requestData);
            request.Header.DataLength = request.Data.Length;

            return request;
        }
    }
}
